﻿@model CompareProductsModel
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.CompareProducts").Text);
}
@using Nop.Web.Models.Catalog;
@{
    string columnWidth = "";
    if (Model.Products.Count > 0)
    {
        columnWidth = Math.Round((decimal)(90M / Model.Products.Count), 0).ToString() + "%";
    }


    var specificationAttributes = new List<ProductSpecificationModel>();
    foreach (var product in Model.Products)
    {
        foreach (var attribute in product.SpecificationAttributeModels)
        {
            if (specificationAttributes.FirstOrDefault(sa => sa.SpecificationAttributeId == attribute.SpecificationAttributeId) == null)
            {
                specificationAttributes.Add(attribute);
            }
        }
    }
}
<div class="page compare-products-page">
    <div class="page-title">
        <h1>@T("Products.Compare.Title")</h1>
    </div>
    <div class="page-body">
        @if (Model.Products.Count > 0)
        {
            <a href="@Url.RouteUrl("ClearCompareList")" data-role="button" data-ajax="false">@T("Products.Compare.Clear")</a>
            <ul data-role="listview" data-inset="true" data-filter="false" data-theme="c">
                @foreach (var product in Model.Products)
                {
                    <li>
                        <div class="item">
                            <div class="remove">
                                <a href="@Url.RouteUrl("RemoveProductFromCompareList", new { productId = product.Id })" class="remove-button" data-role="button" data-ajax="false">@T("Common.Remove")</a>
                            </div>
                            <div class="product-picture">
                                <img alt="@product.DefaultPictureModel.AlternateText" src="@product.DefaultPictureModel.ImageUrl" title="@product.DefaultPictureModel.Title" />
                            </div>
                            <div class="product-name">
                                <a href="@Url.RouteUrl("Product", new { SeName = product.SeName })">@product.Name</a>
                            </div>
                            <div class="product-price">
                                @T("Products.Compare.Price"): @product.ProductPrice.Price
                            </div>
                            <div class="attributes">
                                @foreach (var specificationAttribute in specificationAttributes)
                                {
                                    <div class="attribute">
                                        @specificationAttribute.SpecificationAttributeName:
                                        @{
                                    var foundProductSpec = product.SpecificationAttributeModels.FirstOrDefault(psa => psa.SpecificationAttributeId == specificationAttribute.SpecificationAttributeId);
                                    var specValue = foundProductSpec != null ? foundProductSpec.SpecificationAttributeOption : "";

                                    if (!String.IsNullOrEmpty(specValue))
                                    {
                                            @specValue
                                    }
                                    else
                                    {
                                            <text>&nbsp;</text>
                                    }
                                        }
                                    </div>
                                }
                            </div>
                            @*we do not display descriptions in mobile version even when enabled
                            uncomment the lines below to enabled this option*@
                            @*@if (Model.IncludeShortDescriptionInCompareProducts)
                            {
                                <div class="short-description">
                                    @T("Products.Compare.ShortDescription"): @Html.Raw(product.ShortDescription)
                                </div>
                            }
                            @if (Model.IncludeFullDescriptionInCompareProducts)
                            {
                                <div class="full-description">
                                    @T("Products.Compare.FullDescription"): @Html.Raw(product.FullDescription)
                                </div>
                            }*@
                            @Html.Widget("mobile_compareproducts_row")
                        </div>
                    </li>
                }
            </ul>
        }
        else
        {
            @T("Products.Compare.NoItems")
        }
    </div>
</div>
